package com.jk.admin.controller;

import com.jk.admin.entity.MongUser;
import com.jk.admin.entity.RoleEntity;
import com.jk.admin.entity.User;
import com.jk.admin.service.TreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private TreeService treeService;
    /*
     * @Author 曾义才
     * @Description //TODO 从mongodb 查询用户列表
     * @Date 17:07 2021/3/30
     * @Param [user]
     * @return java.lang.Object
     */
    @ResponseBody
    @RequestMapping("getUser")
    public Object  getUser(MongUser user){
        return  treeService.getUser(user);
    }
    /*
     * @Author 曾义才
     * @Description //TODO 查询用户 
     * @Date 17:08 2021/3/30
     * @Param [user_id]
     * @return com.jk.admin.entity.User
     */
    @ResponseBody
    @RequestMapping("getHui")
    public MongUser  getUser(String id){
        return  treeService.getHui(id);
    }
   /*
    * @Author 曾义才
    * @Description //TODO 用户修改
    * @Date 17:08 2021/3/30
    * @Param [user]
    * @return void
    */
    @ResponseBody
    @RequestMapping("update")
    public void   update(User user){
       treeService.update(user);
    }
    /*
     * @Author 曾义才
     * @Description //TODO 删除用户
     * @Date 17:17 2021/3/30
     * @Param [user_id]
     * @return void
     */
    @ResponseBody
    @RequestMapping("del")
    public void   del(Integer user_id,String id){
        treeService.del(user_id,id);
    }
    /*
     * @Author 曾义才
     * @Description //TODO 添加用户
     * @Date 19:04 2021/3/30
     * @Param [user]
     * @return void
     */
    @ResponseBody
    @RequestMapping("add")
    public void   add(User user){
        treeService.add(user);
    }
    /*
     * @Author 曾义才
     * @Description //TODO 启用
     * @Date 19:06 2021/3/30
     * @Param [user_id]
     * @return void
     */
    @ResponseBody
    @RequestMapping("qi")
    public void   qi(Integer user_id,String id){
        treeService.qi(user_id,id);
    }
     /*
      * @Author 曾义才
      * @Description //TODO 关闭
      * @Date 19:06 2021/3/30
      * @Param [user_id]
      * @return void
      */
    @ResponseBody
    @RequestMapping("guan")
    public void   guan(Integer user_id,String id){
        treeService.guan(user_id,id);
    }
    /*
     * @Author 曾义才
     * @Description //TODO 分配角色
     * @Date 9:52 2021/3/31
     * @Param [user]
     * @return void
     */
    @ResponseBody
    @RequestMapping("update2")
    public void   update2(MongUser user){
        treeService.update2(user);
    }

   /*
    * @Author 曾义才
    * @Description //TODO 分配角色回显
    * @Date 14:23 2021/3/31
    * @Param [id]
    * @return com.jk.admin.entity.MongUser
    */
    @ResponseBody
    @RequestMapping("getHui2")
    public MongUser  getHui2(String id){
        return  treeService.getHui2(id);
    }
    /*
     * @Author 曾义才
     * @Description //TODO 角色列表
     * @Date 14:24 2021/3/31
     * @Param [user]
     * @return java.lang.Object
     */
    @ResponseBody
    @RequestMapping("getRole")
    public List<MongUser> getRole(MongUser mongUser){
        return  treeService.getRole(mongUser);
    }

    /*
     * @Author 曾义才
     * @Description //TODO 编辑角色描述
     * @Date 15:21 2021/4/1
     * @Param [user]
     * @return void
     */
    @ResponseBody
    @RequestMapping("updateRole")
    public void   updateRole(MongUser user){
        treeService.updateRole(user);
    }
}
